FROM centos:centos7

#================= nginx =================
WORKDIR /home/nginx

COPY ./nginx/nginx-1.18.0.tar.gz ./
COPY ./nginx/nginx-http-flv-module-master.zip ./
COPY ./nginx/nginx.service /lib/systemd/system/

RUN yum -y install lrzsz gcc-c++ make pcre pcre-devel zlib zlib-devel unzip openssl openssl-devel \
    && tar -zxvf nginx-1.18.0.tar.gz \
    && unzip nginx-http-flv-module-master.zip \
    && cd nginx-1.18.0 \
    && ./configure --with-http_ssl_module --with-http_secure_link_module --add-module=../nginx-http-flv-module-master \
    && make \
    && make install \
    && systemctl enable nginx.service

COPY ./nginx/nginx.conf /usr/local/nginx/conf/

#================= ffmpeg =================
WORKDIR /home/ffmpeg

COPY ./ffmpeg/ffmpeg-4.3.1.tar.gz ./
COPY ./ffmpeg/yasm-1.3.0.tar.gz ./
COPY ./ffmpeg/x264-master.tar.gz ./

RUN tar -xvf yasm-1.3.0.tar.gz \
	&& cd yasm-1.3.0 \
	&& ./configure \
	&& make \
	&& make install \
	&& cd .. \
	&& tar -xzvf x264-master.tar.gz \
	&& cd x264-master \
	&& ./configure --enable-shared --enable-static --disable-asm --disable-opencl \
	&& make \
	&& make install \
	&& sed -i -e '$a/usr/local/lib' /etc/ld.so.conf \
	&& ldconfig \
	&& cd .. \
	&& tar -xvf ffmpeg-4.3.1.tar.gz \
	&& cd ffmpeg-4.3.1 \
	&& ./configure --prefix=/usr/local/ffmpeg --enable-openssl --enable-nonfree --enable-gpl --enable-libx264 \
	&& make -j 8 \
	&& make install \
	&& ln -s /usr/local/ffmpeg/bin/ffmpeg /usr/bin/ffmpeg \
	&& ln -s /usr/local/ffmpeg/bin/ffprobe /usr/bin/ffprobe

#================= port =================
WORKDIR /home

ENTRYPOINT ["/usr/sbin/init"]

CMD ["/bin/bash"]
